package com.lepu.app.fun.bbs.bean;

import android.text.TextUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

@SuppressWarnings("serial")
public class BeanBbsDetail implements Serializable {
    
	public String PostID;
    public String AuthorID;
    public String NickName;
    public String Avatar;
    public String Subject;  //标题
    public String Content;
    public String PicUrls;
    public long RecordCreateTime;
    public String Isvisible;
    public String IsThread;
    public int FavourCount; //点赞数
    public int CollectCount; //收藏数
    public int ViewCount; //阅读数
    public int ReplyCount; //回复数
    public int HasFavour = 0;
    public int HasCollect = 0;
    public int RefreshMaxID;
    
    public int IsTop;   //是否置顶
    public int IsGood;  //是否精华 0-否，1-是
    public String ForumID;//板块id   1-支架人生 2-支架术后

    public static ArrayList<BeanBbsDetail> parseJsonData(String dataString) {
        String result = "";
        try {
            JSONObject jsonObject = new JSONObject(dataString);
            JSONObject obj1 = (JSONObject) jsonObject.get("Result");
            JSONArray obj2 = (JSONArray) obj1.get("ListInfo");

            result = obj2.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }

        Gson gson = new Gson();
        ArrayList<BeanBbsDetail> testArraylist = gson.fromJson(result,
        		new TypeToken<List<BeanBbsDetail>>() {}.getType());
        return testArraylist;
    }
    
    //解析图片
    public static List<String> parseJsonImage(String imageString){
    	List<String> imageList = new ArrayList<String>();

        if(!TextUtils.isEmpty(imageString))
        {
            String [] imageArray = imageString.split("\\|");
            for(int i=0; i<imageArray.length; i++){
                imageList.add(imageArray[i]);
            }
        }

		return imageList;
    }

}
